package math;

import org.junit.Test;

import java.util.Random;

public class ImplementRand10UsingRand7 {
    @Test
    public void test() {
        for (int i = 0; i < 20; i++) {
            System.out.println(rand10());
        }
    }

    static final Random rand = new Random();
    public int rand7() {
        return rand.nextInt(7) + 1;
    }
    public int rand10() {
        int a;
        int b;
        while ((a=rand7()) > 6) {}
        while ((b=rand7()) > 5) {}
        return a%2==0 ? b*2: b;
    }
}
